<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: yajuan.wang
  Date: 2018/12/12
  Time: 15:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:include page="/pages/sysIndex/default.jsp"/>
<head>
</head>
<style>
    a {
        text-decoration: none;
        color: #0C0C0C;
        font-size: 12px;
    }

    .box-body {
        margin: 10px 10px;
    }

</style>
<div class="main-content">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-trophy"></i> 指派人员
            </div>
                <div class="box-tools pull-right">
                    <a href="#" class="btn btn-default" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
                </div>

        </div>
        <div class="box-body">
            <form id="detailForm" action="<c:url value="/web/admin/repairOrder/getUserByArea.action"/>" method="post"
                  class="form-inline hide" data-page-no="1" data-page-size="20" data-order-by="">
                <input type="hidden" name="repairId" id="repairId" value="${repairId}"/>
                <div class="form-group">
                    <label class="control-label">搜索：</label>
                    <div class="control-inline">
                        <input type="text" id="searchCode" name="searchCode" value="" maxlength="64"
                               class="form-control width-120">
                    </div>
                </div>

                <div class="form-group">
                    <button type="submit" class="btn btn-primary btn-sm">查询</button>
                    <button type="reset" class="btn btn-default btn-sm">重置</button>
                </div>

            </form>
            <table id="assignUserGrid"></table>
            <div id="assignUserGridPage"></div>
            <div class="box-footer">
                <div class="row">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i>
                            保 存
                        </button>&nbsp;

                        <button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="closeView()"><i
                                class="fa fa-times"></i> 关 闭
                        </button>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<script>

    $('#assignUserGrid').dataGrid({
        searchForm: $("#detailForm"),
        showCheckbox: true,
        columnModel: [
            {header: '编号', name: 'id', index: 'id', width: 20, align: "center"},
            {header: '姓名', name: 'userName', index: 'userName', width: 80, align: "center"},
            {header: '手机号', name: 'userAccount', index: 'userAccount', width: 80, align: "center"},
            {header: '工号', name: 'workNo', index: 'workNo', width: 80, align: "center"},
            {header: '部门', name: 'organization', index: 'organization', width: 80, align: "center"},
            {header: '岗位', name: 'position', index: 'position', width: 80, align: "center"},
            {header: '账号类型', name: 'position', index: 'position', width: 80, align: "center"},
            {header: '角色', name: 'roleName', index: 'roleName', width: 80, align: "center"},

        ],
        // 加载成功后执行事件
        ajaxSuccess: function (data) {

        }
    });
    function closeView() {
        console.log("关闭");
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }

    $("#btnSubmit").click(function(){
        var ids = $("#assignUserGrid").jqGrid("getGridParam", "selarrrow");
        console.log(ids);
        $.ajax({
            type: 'post',
            url: "<c:url value="/web/admin/repairOrder/saveAssignList.action" />",
            data: {"assignIds": JSON.stringify(ids), "repairId": $("#repairId").val()},
            dataType: 'json',
            async: false,
            success: function (data) {
                js.showMessage(data.msg);
                closeView();
                $('#dataGrid').dataGrid("refresh");
            },
            error: function () {
                js.showMessage("出错了，请联系管理员");
            }
        });
    })







</script>

